<?php

namespace App\Http\Controllers\Customer\Pages;

use Illuminate\Http\Request;
use App\Facades\DeviceService;
use App\Facades\WeChatService;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class DeviceController extends Controller
{
    //设备状态页面
    public function index(Request $request)
    {
        $state = DeviceService::getState();
        if(is_null($state)){
            $state['deviceCode'] = deviceCode();
        }
        $host = head($request->header()['host']);
        if(array_key_exists('state', $state)){
            $state = array_merge($state['state'], $state['filters']);
        }
        return view("state")->with(wxConfig([
            'state' => $state,
            'host' => $host,
            ], $request));
    }

    //配网页面
    public function connect(Request $request)
    {
        return view("connect")->with(wxConfig([], $request));
    }

    //设备信息, 解绑页面
    public function info(Request $request)
    {
        return view("deviceInfor")->with([
            'device_code' => deviceCode()
            ]);
    }

}
